package com.example.demo.day.config.learn.design.order.x1;

import java.util.ArrayList;
import java.util.List;

public class Broker {
    //买卖股票的命令
    private List<Order> orders;

    public Broker() {
        orders = new ArrayList<>();
    }

    //接收命令
    public void takeOrders(Order o) {
        orders.add(o);
    }

    //执行命令
    public void executeOrders() {
        for (Order o: orders) {
            o.execute();
        }
        orders.clear();
    }
}
